import Page
from Page import SmartHome
from Base.Base import Base
from selenium.webdriver.common.by import By


class SmartHomeIndexPage(Base):
    """
    智能家居首页

    因其页面命名比较特殊, 故直接采用拼音命名
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 智能家居标题
        self.index_title_text = (By.XPATH, Page.TEXT.format("奔腾智能家居平台"))

        # 公子小白封面
        self.index_xiaobai_cover_img = (By.XPATH, SmartHome.RESOURCE_ID.format("iv_xiaobai"))

        # 云米封面
        self.index_yunmi_cover_img = (By.XPATH, SmartHome.RESOURCE_ID.format("iv_cloudmi"))

        # 小米封面
        self.index_xiaomi_cover_img = (By.XPATH, SmartHome.RESOURCE_ID.format("iv_xiaomi"))

    def get_xiaobai(self):
        """
        获取公子小白封面

        :return:
        """
        return self.find_element_o(self.index_xiaobai_cover_img)

    def get_title(self):
        """
        获取智能家居首页标题

        :return:
        """
        return self.find_element_o(self.index_title_text)

    def get_yunmi_cover(self):
        """
        获取云米封面

        :return:
        """
        return self.find_element_o(self.index_yunmi_cover_img)

    def get_xiaomi_cover(self):
        """
        获取小米封面

        :return:
        """
        return self.find_element_o(self.index_xiaomi_cover_img)

    def click_xiaobai_cover(self):
        """
        点击公子小白封面

        :return:
        """
        self.click_element(self.index_xiaobai_cover_img)

    def click_yunmi_cover(self):
        """
        点击云米封面

        :return:
        """
        self.click_element(self.index_yunmi_cover_img)

    def click_xiaomi_cover(self):
        """
        点击小米封面

        :return:
        """
        self.click_element(self.index_xiaomi_cover_img)

    def is_display_smarthome_index(self):
        """
        是否进入智能家居首页

        :return:
        """
        return self.is_display(self.index_xiaomi_cover_img)
